package main

import (
	"fmt"
	"sort"
)

// https://leetcode.cn/problems/assign-cookies/description/
func main() {
	//小孩胃口、饼干大小、能满足几个人
	fmt.Println(findContentChildren([]int{1, 2, 3}, []int{1, 1}))
	fmt.Println(findContentChildren([]int{12, 1, 99}, []int{1, 2, 3, 100, 100}))
}

func findContentChildren(g []int, s []int) int {
	sort.Ints(g)
	sort.Ints(s)
	indexG, indexS, res := 0, 0, 0
	for indexG < len(g) && indexS < len(s) {
		if g[indexG] <= s[indexS] {
			res++
			indexG++
			indexS++
		} else {
			indexS++
		}
	}
	return res
}
